package me.jessyan.mvparms.demo.mvp.ui.activity.auth;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.View;

import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;
import com.jess.arms.utils.DoubleClickUtils;
import com.tbruyelle.rxpermissions2.RxPermissions;

import javax.inject.Inject;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import me.jessyan.mvparms.demo.R;
import me.jessyan.mvparms.demo.di.component.auth.DaggerAuthComponent;
import me.jessyan.mvparms.demo.di.module.auth.AuthModule;
import me.jessyan.mvparms.demo.mvp.contract.auth.AuthContract;
import me.jessyan.mvparms.demo.mvp.presenter.auth.AuthPresenter;
import me.jessyan.mvparms.demo.mvp.ui.widget.CustomToolbar;

import static com.jess.arms.utils.Preconditions.checkNotNull;

/**
 * 实名认证页面
 */
public class AuthActivity extends BaseActivity<AuthPresenter> implements AuthContract.View {
    @Inject
    RxPermissions mRxPermissions;
    @BindView(R.id.toolbar)
    CustomToolbar toolbar;

    @Override
    public void setupActivityComponent(@NonNull AppComponent appComponent) {
        DaggerAuthComponent //如找不到该类,请编译一下项目
                .builder()
                .appComponent(appComponent)
                .authModule(new AuthModule(this))
                .build()
                .inject(this);
    }

    @Override
    public int initView(@Nullable Bundle savedInstanceState) {
        return R.layout.activity_auth; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0
    }

    @Override
    public void initData(@Nullable Bundle savedInstanceState) {
        toolbar.setListener(new CustomToolbar.ToolbarListener() {
            @Override
            public void onLeftBack() {
                killMyself();
            }

            @Override
            public void onRightBack() {

            }
        });
    }

    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }

    @Override
    public void showMessage(@NonNull String message) {
        checkNotNull(message);
        ArmsUtils.snackbarText(message);
    }

    @Override
    public void launchActivity(@NonNull Intent intent) {
        checkNotNull(intent);
        ArmsUtils.startActivity(intent);
    }

    @Override
    public void killMyself() {
        finish();
    }

    @Override
    public AuthActivity getActivity() {
        return this;
    }

    @Override
    public RxPermissions getRxPermissions() {
        return mRxPermissions;
    }



    @OnClick({R.id.bg_one,R.id.bg_two,R.id.commit_tv})
    public void onViewClicked(View view) {
if(DoubleClickUtils.getInstance().isDouble(view)){
    return;
}
switch (view.getId()){
    case R.id.bg_one :
        mPresenter.choicePic(true);
        break;
    case R.id.bg_two:
        mPresenter.choicePic(false);
        break;
    case R.id.commit_tv:
        startActivity(new Intent(AuthActivity.this,AuthResultActivity.class));
        break;
        default:

}

    }
}
